"""后缀表达式"""
from ADT import Stack


def hou_ex(ex):
    res = ''
    prec = {'+': 1, '-': 1, '*': 2, '/': 2, '(': 3}
    stack = Stack()
    for s in ex:
        if s not in '()+-*/':
            res += s
            res += ' '
        elif s == '(':
            stack.push(s)
        elif s == ')':
            opt = stack.pop()
            while opt != '(':
                res += opt
                res += ' '
                opt = stack.pop()
        elif s in '+-*/':
            while not stack.isEmpty() and prec[stack.peek()] > prec[s]:
                if stack.peek() == '(':
                    break
                res += stack.pop()
                res += ' '
            stack.push(s)
    while not stack.isEmpty():
        res += stack.pop()
        res += ' '
    return res


ex = list(input().strip().split())
print(hou_ex(ex))
# 11 + 2 * 3






